package me.spring.cloud.components.starter.cat.configuration;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.dianping.cat.servlet.CatFilter;
import me.spring.cloud.common.components.monitor.aop.CatAopAspect;
import me.spring.cloud.components.starter.cat.dynamic.DynamicCatMonitorConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @description: cat 配置
 * @author: luffy
 * @create: 2018-10-15 14:50
 **/
@Configuration
@EnableApolloConfig
@Import({CatAopAspect.class, DynamicCatMonitorConfiguration.class, ClientConfigProvider.class})
public class CatConfigure {

  @Bean
  public FilterRegistrationBean catFilter() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    CatFilter filter = new CatFilter();
    registration.setFilter(filter);
    registration.addUrlPatterns("/*");
    registration.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico");
    registration.setName("cat-filter");
    registration.setOrder(2);
    return registration;
  }
}
